package com.wujian.love.controller;

import com.wujian.love.redis.RedisDelayingQueue;
import com.wujian.love.result.JSONResult;
import redis.clients.jedis.Jedis;

public class RedisDelayingQueueTestController {

    public static void main(String[] args) {
        Jedis jedis = new Jedis();
        RedisDelayingQueue<String> queue = new RedisDelayingQueue<>(jedis,"test");




        Thread produce = new Thread(){
            public void  run(){
                for (int i = 0;i <10;i++){
                    queue.delay("codehole"+i);
                }
            }
        };

        Thread consumer = new Thread(){
            public void  run(){
                queue.loop();
            }
        };
        produce.start();
        consumer.start();
        try {
            produce.join();
            Thread.sleep(1000);
            consumer.interrupt();
            consumer.join();
        }catch (InterruptedException e){
            System.out.println(e.getMessage());
        }

    }


}
